
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
request.setAttribute("basePath", basePath);
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>${title}</title>
	<style>
		#box{width:1200px;height:1000px;margin:200px auto;}
	</style>
	<link rel="stylesheet" href="${basePath}/static/css/list.css"/>
<link rel="stylesheet" href="${basePath}/static/css/login.css"/>
<link rel="stylesheet" href="${basePath}/static/bootstrap/css/bootstrap.css"/>
<script type="text/javascript" src="${basePath}/static/jquery/jquery.min.js"></script>
<script type="text/javascript" src="${basePath}/static/bootstrap/js/bootstrap.js"></script>
<link href="${basePath}/static/css/basic.css" rel="stylesheet" type="text/css">
</head>
<body>

<!--<div id="div_login" style="display:none;">-->
<div id="box">
<div id="div_login"">

 <div class="login">
  <ul>
  	<form action="${basePath}/user/userLogin" method="post" id="form1">
  	
  		<li>
						<p style="width: 65px; float: left;">用户名：</p>
						<p style="float: left; width: 100px;">
						<INPUT style="float: none;" name="loginName"id="loginName" type="text" class="textbox" value="${loginName }">
						</p>
						</li>
						
						<li>
							<p style="width: 65px; float: left;">密 &nbsp;码：</p>
							<p style="float: left; width: 100px;">
								<INPUT style="float: none;" name="password"
								id="txtPwd" type="password" class="textbox" value="${password }">
							</p>
						</li>
  					<li><span onclick="createCode()" style="letter-spacing:5px" id="checkCode"></span>
  					<p style="width: 65px; float: left;">验证码：</p>
  					<INPUT name="txtName" id="txtName" type="text" class="check" value=""></li>
 					<li style="display: none;"><span id="errorMsg">${errorMsg}</span></li>
 	 <!-- 
 	 <li>机&nbsp;&nbsp;&nbsp;构:<select name="orgCode" class="textbox"><option selected="selected" value="49557184-0">山东省立医院</option></select></li> 
 	  -->
  	 <li><a><INPUT name="btnLogin" class="L_up" id="btn_login" onclick="login()"
								type="button" value="登&nbsp;&nbsp;录"></a> <a><INPUT
								name="btnLogin" class="L_up2" id="closeBtn" type="button"
								value="清&nbsp;&nbsp;空"></a></li>
   </form>
 </ul>
 </div>

</div>
</div>
</body>
<script type="text/javascript">
$("#closeBtn").on('click',function(){
	$("#loginName").val("");
	$("#txtPwd").val("");
	$("#txtName").val("");
	createCode();
});
$(function() {
	var errorMsg = $("#errorMsg").text();
	if(errorMsg != null && errorMsg != '') {
		alert(errorMsg);
	}
});
$(function(){
	createCode();
});

	 var code; //在全局 定义验证码    
    function createCode() {  
        code = "";  
        var codeLength = 4;//验证码的长度       
  
        var selectChar = new Array(2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D',  
                'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R',  
                'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');  
  
        for (var i = 0; i < codeLength; i++) {  
            var charIndex = Math.floor(Math.random() * 32);  
            code += selectChar[charIndex];  
        }  
        if (code.length != codeLength) {  
            createCode();  
        }  
        $("#checkCode").html(code);  
    }  
  
    function validate() {  
        var inputCode = document.getElementById('txtName').value.toUpperCase();
        if (inputCode.length <= 0) {  
            alert("请输入验证码！");  
            return false;  
        } else if (inputCode != code) {  
            alert("验证码输入错误！");  
            createCode();  
            return false;  
        } else {  
            return true;  
        }  
  
    }  
    
    
    function login(){
    	var userName= $("#loginName").val();
    	var password=$("#txtPwd").val();
    	if(!userName){
    		alert("用户名不能为空!");
    		return;
    	}
    	if(!password){
    		alert("密码不能为空!");
    		return;
    	}
    	//校验验证码登陆
    	if(validate()){
    		$("#form1").submit();
    	}
    	
    }
</script>
</html>
